<?php
@session_start();
 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';

/*
 *  A Part of snock project
 *   Author king-of-war
 * Last modified 2009-4-22
 *
 */
 $root_path='../';
 include_once $root_path . 'admin/smarty_config.php';
include_once $root_path . 'admin/class/fun_common.php';
include_once $root_path . 'admin/class/pro.class.php';

/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(3);

$pro=new pro($root_path);
$fun = new fun_common($root_path);

$max = $fun->getAll('products', 1);
/*
 * page moudle start
 *
 */
 include_once $root_path . 'admin/class/cfg.class.php';
$cfg=new cfg($root_path);
  $page_size=$cfg->xml_read('page_num');
if (!empty ($_GET['p'])) {
	$page = $_GET['p'];
} else {
	$page = 1;
}
$pages = $fun->page($page, $page_size, $max);
/*
 * page moulde  end
 *  sort_read($arr)
 */
$arr[0] = $pages['start'];
$arr[1] = $page_size;
/*
 * get the comment of sorts
 */
$products=array();

$pass=$pro->products_get($arr);

for($i=0;$i<count($pass);$i++){
	$products[$i]['id']=$pass[$i]->get_id();
	  $products[$i]['sort_id']=$pass[$i]->get_sort_id();
    $products[$i]['name']=$pass[$i]->get_name();
$products[$i]['image']=$pass[$i]->get_images();
    $products[$i]['introduction']=$pass[$i]->get_introduction();


}


/*
 * sort delete moudle
 */

if (isset($_POST['Submit'])) {

//	$ids = array ();
		$t=0;
	for ($i = 0; $i < $max; $i++) {

		$id = $products[$i]['id'];

		if ($_POST[$id]!= '') {

			$ids[$t]=$id;
			$t++;
		}

	}



	 $line=$pro->products_del($ids);

if($line){
	echo '<div align="center"><h1>成功删除'.$line.'条产品</h1></div>';
}else{
	echo '<div align="center"><h1>删除失败</h1></div>';
};
}

$smarty->assign("products", $products);
$smarty->assign("page", $pages);
$smarty->assign("url", $root_path);
$smarty->display("pro_del.html");

?>


